﻿@{
    ViewBag.Title = "RoleIndex";
}
@*@model string*@
@section head
{
    <link href="@Url.Content("~/ScriptPlugin/easyui/themes/gray/easyui.css")" rel="stylesheet" />
    <link href="@Url.Content("~/ScriptPlugin/easyui/themes/icon.css")" rel="stylesheet" />
    <script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/jquery.easyui.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/locale/easyui-lang-zh_CN.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/KingsSharp.DataGrid.Filter.js")"></script>
    <script src="@Url.Content("~/ScriptPlugin/WdatePicker/js/WdatePicker.js")"></script>
@*<script src="@Url.Content("~/ScriptPlugin/ztree/js/jquery.ztree.core-3.5.js")" type="text/javascript"></script>
<link href="@Url.Content("~/ScriptPlugin/ztree/css/zTreeStyle/zTreeStyle.css")" rel="stylesheet" type="text/css" />*@
}
<div style="float:left;width:190px;height:100%;display:none">
    <div class="content-bar-color" style="height: 34px; line-height: 34px; text-align: center;font-size:14px;">
        机构列表
    </div>
    <ul id="OrganizationList" class="ztree"></ul>
</div>
<div id="grid">
    <div id="toolpannel">
        <div class="content-pannel-buttons">
            <a><b class="p-icon-reload">刷新 </b></a><a onclick="RoleAdd()">
                <b class="p-icon-add">
                    新增
                </b>
            </a><a onclick="RoleEdit()"><b class="p-icon-edit">编辑</b></a>
            <a onclick="RoleDelete()"><b class="p-icon-delete">删除</b></a>
            <a onclick="$('#grid').datagrid('load')">
                <b class="p-icon-serch">查询</b>
            </a>
        </div>
        <div class="datagrid-filter-pannel" id="filterpannel">
            <table class="content-table-serch">
                <tr>
                    <th>
                        角色名称
                    </th>
                    <td>
                        <input type="text" name="Name" data-filter="true" />
                        <a class="p-icon-filter p-icon-filter-style" style="display: block; width: 22px;
                        height: 22px; float: left">@Html.GetFilterItem("Name", typeof(string))</a>
                    </td>
                    <th>

                    </th>
                    <td></td>
                    <th>

                    </th>
                    <td></td>
                    <th>

                    </th>
                    <td></td>
                </tr>
            </table>
        </div>
    </div>
</div>
    @section foot{
        <script type="text/javascript">
            @*var jsonTree = @MvcHtmlString.Create(Model);
            var zTree = $.fn.zTree.init($("#OrganizationList"), {}, jsonTree);*@
            function LoadUserInfoData() {
                var columns = [[
                        { field: "Name", title: "角色名称", width: 130 },
                        { field: "Order", title: "排序号", width: 40 },
                        { field: "IsLocked", title: "是否锁定", width: 70 },
                        { field: "IsAdmin", title: "是否管理员角色", width: 100 },
                        { field: "IsSystem", title: "是否系统角色", width: 90 },
                        { field: "Remark", title: "角色备注"}
                ]];
                var parameter = {
                    title: "@Html.GetGridTitle("系统管理","角色设置")",
                    columns: columns,
                    url: "@Url.Content("~/Sys/Role/GetRoleGridData")",
                    pageNumber: 1
                };
                var grid = K.GetGridData("#grid", parameter).Grid;
            }
            LoadUserInfoData();

            function RoleAdd() {
                K.layer.iframe({
                    title: "@Html.GetLayerTitle(LayerIcon.Add,"新增角色")",
                    content: "@Url.Content("~/Sys/Role/RoleAdd")",
                    maxmin: true,
                    initfull: true,
                    btn: ["保存", "返回"],
                    callback: function (result) {
                        if (K.ShowOrAlert(result)) {
                            $("#grid").datagrid("load");
                        }
                    }
                });
            }
            function RoleEdit() {
                var row = $("#grid").datagrid("getSelected");
                if (row == null) {
                    K.Alert("请选择需编辑的行");
                    return false;
                }
                K.layer.iframe({
                    title: "@Html.GetLayerTitle(LayerIcon.Edit,"编辑角色")",
                    content: "@Url.Content("~/Sys/Role/RoleEdit")?RoleId=" + row.Id,
                    maxmin: true,
                    initfull: true,
                    btn: ["保存", "返回"],
                    callback: function (result) {
                        if (K.ShowOrAlert(result)) {
                            $("#grid").datagrid("load");
                        }
                    }
                });
            }
            function RoleDelete() {
                var row = $("#grid").datagrid("getSelected");
                if (row == null) {
                    K.Alert("请选择需删除的行");
                    return false;
                }
                K.Confirm("确认删除角色 \"" + row.Name + "\" ？", function () {
                    K.AjaxJson("@Url.Content("~/Sys/Role/RoleDelete")", { RoleId: row.Id, RoleName: row.Name }, function (result) {
                        if (K.ShowOrAlert(result)) {
                            $("#grid").datagrid("load");
                        }
                    });
                });
            }
        </script>
    }